package org.absolutezero.client.util;


import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

public class Dialog {

	
	public static void show(String caption, String message){
		
		final DialogBox dialog = new DialogBox();
		dialog.setText(caption);
		
		VerticalPanel panel = new VerticalPanel();
		Label msg = new Label(message);
		Button b = new Button("OK");
		b.addClickHandler(new ClickHandler(){

			@Override
			public void onClick(ClickEvent event) {
				dialog.hide();
			}
			
		});
		panel.add(msg);
		panel.add(b);
		
		panel.setCellHorizontalAlignment(b, HasHorizontalAlignment.ALIGN_RIGHT);
		
		dialog.setWidget(panel);
		
		dialog.center();
		dialog.show();
		
	}
}
